#include <iostream>
#include <string>
#include <vector>
using namespace  std;

class Solution{
public:
    string minNumber(vector<int>& nums) {
        quickSort(nums, 0, nums.size() - 1);
        string res;
        for(int i = 0; i < nums.size(); i++){
            res += to_string(nums[i]);
        }
        return res;
    }
    void quickSort(vector<int>& nums, int l, int r){
        if(l >= r) return ;
        int i = l;
        int j = r ;
        while(i < j){
            if(i < j &&  compare(nums[j], nums[l], true )) j--;
            if(i < j && !compare(nums[i], nums[l], false)) i++;
            swap(nums[i], nums[j]);
        }
        swap(nums[i], nums[l]);
        quickSort(nums, l, i - 1);
        quickSort(nums, i + 1, r);
    }
    bool compare(int i, int j, bool eq){
        string ij = to_string(i) + to_string(j);
        string ji = to_string(j) + to_string(i);

        return eq? atoi(ij.c_str()) >= atoi(ji.c_str()) : atoi(ij.c_str()) > atoi(ji.c_str());
    }
};
int main() {

    vector<int> nums({3, 30, 34, 5, 9});
    Solution solve;
    solve.minNumber(nums);
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
